<template>
  <div class="body">
        <van-sticky class="nav">
      <van-nav-bar title="修改密码">
        <template #left>
          <van-icon name="arrow-left" color="#ddd" @click="$router.go(-1)" size="25px" />
        </template>
      </van-nav-bar>
    </van-sticky>
    <!-- 修改密码框 -->
    <van-cell-group>
      <van-field
        v-model="newpwd"
        label="新密码"
        placeholder="输入新密码"
      />
    </van-cell-group>
    <van-button @click="update()" type="primary" size="large" color="#ffc94b" style="font-size: 26px; margin: 0 10px; width: 90%; font-weight: bold; font-size: 20px;">修改密码</van-button>
  </div>
</template>

<script setup>
import { useRoute } from "vue-router";
import { ref,onMounted,reactive} from "vue";
// import { useStore } from "vuex";
import { meApi } from "@/http/apis/meApi"
import router from "@/router";


const u_id = ref(useRoute().params.id);
//在vuex里拿到数据
// let store1 = reactive(useStore().state.user);
// const u_pwd=store1.u_pwd

let newpwd=ref([])

function update(){
   console.log(newpwd.value)
  let params={u_id:u_id.value,u_pwd:newpwd.value}
   meApi.updateUserpwd(params).then(res=>{
    // console.log(res.data.code)
    if(res.data.code==200){
      router.push('/login')
    }
   })
}

onMounted(()=>{
  // console.log(u_pwd)
})
</script>

<style lang="scss" scoped></style>
